package com.haidong.string;

import java.util.Random;

public class StringTest {
    public static void main(String[] args) {
        //1.定义可能会出现的字符信息
        String datas = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

        //2.循环5次,随机产生一个随机索引
        String code = "";
        Random r = new Random();
        for (int i = 0; i < 5; i++) {
            //随机出一个索引
            int index = r.nextInt(datas.length());
            char c = datas.charAt(index);
            code += c;
        }

        //3.直接输出产生的字符串
        System.out.println(code);
    }
}
